package main

import (
	"fmt"
)

type Animal interface {
	Talk()
	Eat()
	Name() string
}
type Dog struct {
}

func (d Dog) Talk() {
	fmt.Println("汪汪")

}
func (d Dog) Eat() {
	fmt.Println("我再吃骨头")

}
func (d Dog) Name() string {
	fmt.Println("我的名字叫旺财")
	return "旺财"

}

type Pig struct {
}

func (p Pig) Talk() {
	fmt.Println("坑坑坑")

}
func (p Pig) Eat() {
	fmt.Println("我再吃草")

}
func (p Pig) Name() string {
	fmt.Println("我的名字叫猪八戒")
	return "猪八戒"

}
func main() {
	var d Dog
	var a Animal
	a = d

	a.Eat()
	a.Talk()
	a.Name()

	var p Pig
	a = p
	a.Eat()
	a.Talk()
	a.Name()
}
